home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / utility1 / ini10.zip / STRING.I < prev    next >
Text File  |  1991-12-31  |  2KB  |  54 lines

  1.  
  2. // a, b, p, q & r should be of "char [{near|far}] *" form
  3.  
  4.     // the following are boolean in nature
  5.  
  6. #define IsStrNULL(p)    (!(p))        // NULL?
  7. #define IsStrNull(p)    (!*(p))     // Null ("" or "\0")?
  8.  
  9. #define IsStrEqual(a,b) (!strcmp(a,b))    // equal?
  10. #define IsStrEquiv(a,b) (!stricmp(a,b)) // equivalent?
  11.  
  12. #define IsStrOnly    !StrVerify    // verifies chars are in string
  13.  
  14.     // the following are of "p = StrFunction(q, r)" form
  15.  
  16. #define StrNull(q)    strchr(q,'\0')
  17.             // find string-end Null;  p -> null terminator
  18.  
  19. #define StrCrop(q,r)    (StrTrunc(q,r),StrLeft(q,r))
  20.             // crop both ends, copy;  p==q:  first non-"r"-char
  21.  
  22. #define StrLeft(q,r)    strcpy(q,StrSkip(q,r))
  23.             // crop left side, copy;  p==q:  first non-"r"-char
  24. #define StrLeftTo(q,r)    strcpy(q,StrSkipTo(q,r))
  25.             // crop left side, copy;  p==q:  first "r"-char
  26.  
  27. #define StrSkip(q,r)    (&(q)[strspn(q,r)])
  28.             // skip chars in "r";     p -> first non-"r"-char
  29. #define StrSkipTo(q,r)    (&(q)[strcspn(q,r)])
  30.             // skip to char in "r";   p -> first "r"-char
  31.  
  32. #define StrPlural(n,s,p) ((n)==1?(s):(p))
  33.             // if singular: "", "y"; if plural: "s", "es", "ies"
  34.  
  35.     // BEWARE OF SIDE EFFECTS IN THE FOLLOWING
  36.  
  37. #define SubStrCL(to,from,col,len)    SubStr(to,from,(col)-1,len)
  38. #define SubStrCC(to,from,col1,col2)    SubStr(to,from,(col1)-1,(col2)-(col1)+1)
  39. #define SubStrOO(to,from,off1,off2)    SubStr(to,from,off1,(off2)-(off1)+1)
  40. #define SubStrOL            SubStr    // (to,from,off,len)
  41.  
  42.     // the following are of "p = StrFunction(q, r)" form
  43.  
  44. #define TABSTOPS    8    // columns per tab in StrDetab and StrEntab
  45.  
  46. extern    char    *StrDetab(char *);        // remove tabs, expanding
  47. extern    char    *StrEntab(char *);        // insert tabs, contracting
  48. extern    char    *StrIndex(char *, char *);    // same as MS-C "strstr"
  49. extern    char    *StrTrunc(char *, char *);    // truncates chars from end
  50. extern    char    *StrUcLc(char *);        // makes upper/lower case
  51. extern    char    *StrVerify(char *, char *);    // verifies chars are in string
  52. extern    char    *SubStr(char *, char *, int, int);    // PL/I "substr"
  53.  
  54.